﻿using SuperJoe.Framework.Core.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WWX.Dto;
using WWX.Model;

namespace WWX.Admin.Web.Models
{
    public class RechargeVM
    {
        public string Account { get; set; }

        public decimal? Amount { get; set; }

        public decimal ZAmount { get; set; }

        public DateTime? Date { get; set; }

        public string Remark { get; set; }

        private void Validate()
        {
            if (Account.IsNullOrWhiteSpace())
            {
                ThrowHelper.ThrowFriendlyException("请输入会员账号");
            }

            if (Amount == null)
            {
                ThrowHelper.ThrowFriendlyException("请输入充值金额");
            }

            if (Date == null)
            {
                ThrowHelper.ThrowFriendlyException("请输入充值日期");
            }
        }

        public RechargeAdminSaveDto ToRechargeSaveDto()
        {
            this.Validate();
            return new RechargeAdminSaveDto()
            {
                Account = this.Account,
                Amount = this.Amount.Value,
                ZAmount = this.ZAmount,
                Remark = this.Remark,
                Date = this.Date.Value
            };
        }
    }
}